-- MRLC_SupportFunctions
-- Author: yiboy
-- DateCreated: 11/29/2024 11:44:46 PM
--------------------------------------------------------------
function playerHasPositiveNumberProperty(playerID, propertyKey)
	local pPlayer = Players[playerID]
	if pPlayer == nil then
		return false
	end

	local property = pPlayer:GetProperty(propertyKey) or 0;
	if type(property) ~= "number" then
		return false
	end

	if property > 0 then
		return true
	else
		return false
	end

end

-- ===========================================================================
function TableIncludeValue(ttable, vvalue)
	for k, v in pairs(ttable) do
		if v == vvalue then 
		return true;
		end
	end
	return false;
end


-- ===========================================================================
function MyStringSplit(str,reps)
    local resultStrList = {}
    string.gsub(str,'[^'..reps..']+',function (w)
        table.insert(resultStrList,w)
    end)
    return resultStrList
end


function MyGetNumber(str)
	local num = ""
	local flg = 0
	while string.len(str) > 0 do
		local c = string.sub(str, 1, 1)
		if c >= "0" and c <="9" then
			num = num .. c
			flg = 1
		elseif c == "-" and flg == 0 then
			num = c
		elseif c == "." then
			num = num .. c
		elseif flg > 0 then
			break
		else
			num = ""
		end
		
		if string.len(str) > 1 then
			str = string.sub(str, 2)
		else
			str =""
		end
	end
 
	return num, str
end

function MyGetNumbersInString(str)
	local my_str = str

	local number_list = {}

	while string.len(my_str) > 0 do
		n, my_str = MyGetNumber(my_str)
		--print(n, my_str)

		table.insert(number_list, tonumber(n))
	end

	return number_list
end
 
 
